package com.platform.destiny.config;

import com.platform.destiny.dto.Result;
import com.platform.destiny.exception.AppException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Description
 * @Author kaiyang
 * @Date 2024-01-30 4:34 PM
 */


@Slf4j
@ControllerAdvice
public class ExceptionController {

    /**
     * 处理错误信息
     */
    @ExceptionHandler(value = {AppException.class, NullPointerException.class})
    public ModelAndView handlePageException(Exception ex) {
        ModelAndView view = new ModelAndView("error");
        view.addObject("message", ex.getMessage());
        return view;
    }
}
